#pragma once

#include "Entity.h"
#include "IComponent.h"

namespace ZeEngine
{
    class Event;
    class GameEngine;

    class IComponentSystem
    {
        friend class EntityManager;

    public:
        IComponentSystem();
        virtual ~IComponentSystem() {}

        virtual bool Init(GameEngine& gameEngine) { return true; }
        virtual void PreUpdate(GameEngine& gameEngine){}
        virtual bool Update(GameEngine& gameEngine) { return true; }
        virtual void PostUpdate(GameEngine& gameEngine){}
        virtual void Destroy(GameEngine& gameEngine) {}
        virtual void Render(SDL_Renderer& renderer, GameEngine& gameEngine, float interpolation) {}

        const u32 GetSystemID() const { return m_id; }

    protected:
        bool IsEntitySupported(const Entity* pEntity);

        void AddRequiredComponent(const std::string& name);
        void AddNeedAtLeastOneComponent(const std::string& name);

    private:
        static u32  m_currentID;
        u32         m_id;
        u64         m_requiredComponents;
        u64         m_needAtLeastOneComponent;
    };
}

